<template>
  <div>
    <van-button type="default">默认按钮</van-button>
    <van-button type="primary">主要按钮</van-button>
    <van-button type="info">信息按钮</van-button>
    <van-button type="warning">警告按钮</van-button>
    <van-button type="danger">危险按钮</van-button>
  </div>
</template>

<script>
export default {
  created () {
    // 基础理解 then和catch,()里函数体 ,return 的值,都会赋予下个then
    const pA = new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve('假设ajax成功')
        // reject(new Error('假如ajax报错了'))
      }, 1000)
    })
    const pB = pA.then(res => {
      return [null, res]
    }).catch(err => {
      return [err, null]
    })
    async function a () {
      const [err, res] = await pB
      if (err) {
        console.log('失败了' + err.toString())
      } else {
        console.log(res)
      }
    }
    a()
  }
}
</script>

<style>
</style>
